/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.TSPSolution.view;

import javax.swing.JPanel;
import pe.edu.pucp.dp1.TSPSolution.view.componentes.Index;

/**
 *
 * @author walter
 */
public class Frm_ConsultarVuelo extends javax.swing.JPanel {

    /**
     * Creates new form Frm_ConsultarVuelo
     */
    public Frm_ConsultarVuelo() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        btnBuscarVuelo = new javax.swing.JButton();
        btnCancelarBuscarVuelo = new javax.swing.JButton();
        txtFechaVuelo = new javax.swing.JTextField();
        lblFechaVuelo = new javax.swing.JLabel();
        txtDestinoVuelo = new javax.swing.JTextField();
        lblDestinoVuelo = new javax.swing.JLabel();
        lblOrigenVuelo = new javax.swing.JLabel();
        txtOrigenVuelo = new javax.swing.JTextField();
        btnLimpiarBuscarVuelo = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBuscarVuelo = new javax.swing.JTable();
        btnRegistrarVuelos = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Consultar Vuelo"));

        btnBuscarVuelo.setText("Buscar");
        btnBuscarVuelo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnBuscarVueloMouseReleased(evt);
            }
        });

        btnCancelarBuscarVuelo.setText("Cancelar");
        btnCancelarBuscarVuelo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCancelarBuscarVueloMouseReleased(evt);
            }
        });

        lblFechaVuelo.setText("Fecha");

        lblDestinoVuelo.setText("Destino");

        lblOrigenVuelo.setText("Origen");

        btnLimpiarBuscarVuelo.setText("Limpiar");
        btnLimpiarBuscarVuelo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnLimpiarBuscarVueloMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblOrigenVuelo)
                        .addGap(18, 18, 18)
                        .addComponent(txtOrigenVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(24, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblDestinoVuelo)
                            .addComponent(lblFechaVuelo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtFechaVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtDestinoVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(btnBuscarVuelo)
                        .addGap(31, 31, 31)
                        .addComponent(btnLimpiarBuscarVuelo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnCancelarBuscarVuelo)
                        .addGap(50, 50, 50))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblOrigenVuelo)
                    .addComponent(txtOrigenVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblDestinoVuelo)
                    .addComponent(txtDestinoVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblFechaVuelo)
                    .addComponent(txtFechaVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBuscarVuelo)
                    .addComponent(btnCancelarBuscarVuelo)
                    .addComponent(btnLimpiarBuscarVuelo))
                .addGap(0, 12, Short.MAX_VALUE))
        );

        tblBuscarVuelo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Código", "Origen", "Destino", "Fecha"
            }
        ));
        jScrollPane1.setViewportView(tblBuscarVuelo);

        btnRegistrarVuelos.setText("Nuevo");
        btnRegistrarVuelos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarVuelosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(159, 159, 159)
                .addComponent(btnRegistrarVuelos)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnRegistrarVuelos)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarVueloMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnBuscarVueloMouseReleased
        // TODO add your handling code here:
        buscar() ;
    }//GEN-LAST:event_btnBuscarVueloMouseReleased

    private void btnLimpiarBuscarVueloMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarBuscarVueloMouseReleased
        // TODO add your handling code here:
        limpiar() ;
    }//GEN-LAST:event_btnLimpiarBuscarVueloMouseReleased

    private void btnCancelarBuscarVueloMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarBuscarVueloMouseReleased
        // TODO add your handling code here:
        cerrar() ;
    }//GEN-LAST:event_btnCancelarBuscarVueloMouseReleased

    private void btnRegistrarVuelosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarVuelosActionPerformed
        // TODO add your handling code here:
        Frm_RegistrarVuelos frm = new Frm_RegistrarVuelos() ;
        cambiarVista( frm ) ;
    }//GEN-LAST:event_btnRegistrarVuelosActionPerformed

    private void cambiarVista( JPanel panel ){
        ((Index)(this.getTopLevelAncestor())).changeContentPane( panel );
    }
    
    private void limpiar(){
        txtDestinoVuelo.setText( "" ) ;
        txtOrigenVuelo.setText( "" ) ;
        txtFechaVuelo.setText( "" ) ;
    }
    
    private void buscar(){
        this.tblBuscarVuelo.setVisible( true ) ;
    }
    
    private void cerrar(){
        this.setVisible( false ) ;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarVuelo;
    private javax.swing.JButton btnCancelarBuscarVuelo;
    private javax.swing.JButton btnLimpiarBuscarVuelo;
    private javax.swing.JButton btnRegistrarVuelos;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblDestinoVuelo;
    private javax.swing.JLabel lblFechaVuelo;
    private javax.swing.JLabel lblOrigenVuelo;
    private javax.swing.JTable tblBuscarVuelo;
    private javax.swing.JTextField txtDestinoVuelo;
    private javax.swing.JTextField txtFechaVuelo;
    private javax.swing.JTextField txtOrigenVuelo;
    // End of variables declaration//GEN-END:variables
}
